package com.destinomusical.epura.adapter;

//Need the following import to get access to the app resources, since this
//class is in a sub-package.
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.destinomusical.epura.obj.Cancion;
import com.destinomusical.epura.obj.Suscripciones;
import com.smartthinking.destinomusical.R;

public class SubscriptionListAdapter extends BaseAdapter {
	List<?> mdataObjectList;
	private LayoutInflater inflater;

	public SubscriptionListAdapter(Activity a, List<?> dataObjectList) {
		mdataObjectList = dataObjectList;
		inflater = (LayoutInflater) a
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return mdataObjectList.size();
	}

	@Override
	public Object getItem(int position) {
		return mdataObjectList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	public void deleteItem(int position) {
		mdataObjectList.remove(position);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		Suscripciones obj = (Suscripciones) mdataObjectList.get(position);
		View vi = convertView;
		final ViewHolder holder;

		if (vi == null) {
			vi = inflater.inflate(R.layout.listitem_song, null);
			holder = new ViewHolder();
			holder.title = (TextView) vi.findViewById(R.id.title);
			holder.desc = (TextView) vi.findViewById(R.id.desc);
			vi.setTag(holder);
		} else {
			holder = (ViewHolder) vi.getTag();
		}
		holder.title.setText("Inicio: "+obj.getFecha_ini() + " / Fin: " + obj.getFecha_fin());
		holder.desc.setText(obj.getStatus());

		return vi;
	}

	public static class ViewHolder {
		public TextView title;
		public TextView desc;
	}

}